package jdbc;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Scanner;

public class JdbcDemo8
{
    public static void main(String[] args)
    {
        // 修改
        try(Connection connection = DBUtil.getConnection())
        {
            String sql = "update userinfo1 set username = ?,password= ? , nickname = ? where id = ?";
            PreparedStatement preparedStatement = connection.prepareStatement(sql);
            preparedStatement.setString(1,"333");
            preparedStatement.setString(2,"******");
            preparedStatement.setString(3,"⚪⚪⚪");
            preparedStatement.setInt(4,2);
            int i = preparedStatement.executeUpdate();
            if (i > 0 )
            {
                System.out.println("change successfully");
            }
            else
            {
                System.out.println("change failed");
            }
        }catch (SQLException e)
        {
            e.printStackTrace();
        }
    }
}
